package com.owen.oauth2.jwt.controller;

import org.springframework.security.jwt.Jwt;
import org.springframework.security.jwt.JwtHelper;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {

    @RequestMapping("/test")
    public String test(@RequestHeader("Authorization") String authorization){
        String token = authorization.substring(7);
        Jwt decode = JwtHelper.decode(token);
        return decode.getClaims();
    }

}
